﻿using Microsoft.AspNetCore.Authorization;
using Simple.Services.System;

namespace Simple.WebApi.Controllers.System
{
    /// <summary>
    /// 幼儿考勤规则
    /// </summary>
    [Route("api/ChildAttendanceRule/[action]")]
    [ApiController]
    [Authorize]
    public class ChildAttendanceRuleController : ControllerBase
    {
        private readonly ChildAttendanceRuleService _childAttendanceRuleService;

        public ChildAttendanceRuleController(ChildAttendanceRuleService childAttendanceRuleService)
        {
            _childAttendanceRuleService = childAttendanceRuleService;
        }

        /// <summary>
        /// 考勤查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<AppResult> Get()
        {
            ChildAttendanceRuleDto data = await _childAttendanceRuleService.GetAsync();
            return AppResult.Status200OK(data: data);
        }

        /// <summary>
        /// 幼儿考勤规则编辑
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<AppResult> Add([FromBody] CreateChildAttendanceRuleInput input)
        {
            await _childAttendanceRuleService.CreateNewRule(input);
            return AppResult.Status200OK("编辑成功");
        }
    }
}
